package com.yidu.ruifeng_logistics;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author: 肖楚科
 * @date: 2021/3/4
 * @time: 14:19
 * @blog: com.yidu.springbootdemo
 * @description: swagger配置
 */
@Configuration//配置注解
@EnableSwagger2//开启Swagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors
                .basePackage("com.yidu.ruifeng_logistics.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(getApinfo());
    }

    public ApiInfo getApinfo(){
        ApiInfo info = new ApiInfoBuilder()
                .title("瑞丰物流系统说明说1.0版")//标题
                .contact(new Contact("xxx","http://baidu.com","1016261131@qq.com"))//联系方式
                .description("瑞丰物流swagger文档")//说明
                .version("1.0")//版本号
                .termsOfServiceUrl("http://baidu.com")//服务地址
                .build();

        return info;
    }



}
